package cn.zust.edu.cn;

public class Circle implements IShape{

    Point ptCenter;
    int radius;

    public Circle(Point center, int r) {
        this.ptCenter = center;
        this.radius = r;
    }

    @Override
    public double perimeter() {
        return 2 * Math.PI * radius;
    }

    @Override
    public double area() {
        return Math.PI * radius * radius;
    }

    @Override
    public void draw() {
        int diameter = 2 * radius;
        for (int y = -radius; y <= radius; y++) {
            for (int x = -radius; x <= radius; x++) {
                double distance = Math.sqrt(x * x + y * y);
                if (distance >= radius - 0.5 && distance <= radius + 0.5) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}
